home *** CD-ROM | disk | FTP | other *** search
/ Inter.Net 55-1 / Inter.Net 55-1.iso / CBuilder / Setup / BCB / data.z / set.h < prev    next >
Encoding:
C/C++ Source or Header  |  1998-02-09  |  22.1 KB  |  664 lines

  1. #ifndef __STD_SET__
  2. #define __STD_SET__
  3. #pragma option push -b -a4 -Vx- -Ve- -w-inl -w-aus -w-sig
  4.  
  5. /***************************************************************************
  6.  *
  7.  * set - declarations for the Standard Library set class
  8.  *
  9.  * $Id: set,v 1.49 1996/09/11 23:03:17 smithey Exp $
  10.  *
  11.  ***************************************************************************
  12.  *
  13.  * Copyright (c) 1994
  14.  * Hewlett-Packard Company
  15.  *
  16.  * Permission to use, copy, modify, distribute and sell this software
  17.  * and its documentation for any purpose is hereby granted without fee,
  18.  * provided that the above copyright notice appear in all copies and
  19.  * that both that copyright notice and this permission notice appear
  20.  * in supporting documentation.  Hewlett-Packard Company makes no
  21.  * representations about the suitability of this software for any
  22.  * purpose.  It is provided "as is" without express or implied warranty.
  23.  *
  24.  *
  25.  ***************************************************************************
  26.  *
  27.  * (c) Copyright 1994, 1995 Rogue Wave Software, Inc.
  28.  * ALL RIGHTS RESERVED *
  29.  * The software and information contained herein are proprietary to, and
  30.  * comprise valuable trade secrets of, Rogue Wave Software, Inc., which
  31.  * intends to preserve as trade secrets such software and information.
  32.  * This software is furnished pursuant to a written license agreement and
  33.  * may be used, copied, transmitted, and stored only in accordance with
  34.  * the terms of such license and with the inclusion of the above copyright
  35.  * notice.  This software and information or any other copies thereof may
  36.  * not be provided or otherwise made available to any other person.
  37.  *
  38.  * Notwithstanding any other lease or license that may pertain to, or
  39.  * accompany the delivery of, this computer software and information, the
  40.  * rights of the Government regarding its use, reproduction and disclosure
  41.  * are as set forth in Section 52.227-19 of the FARS Computer
  42.  * Software-Restricted Rights clause.
  43.  * 
  44.  * Use, duplication, or disclosure by the Government is subject to
  45.  * restrictions as set forth in subparagraph (c)(1)(ii) of the Rights in
  46.  * Technical Data and Computer Software clause at DFARS 252.227-7013.
  47.  * Contractor/Manufacturer is Rogue Wave Software, Inc.,
  48.  * P.O. Box 2328, Corvallis, Oregon 97339.
  49.  *
  50.  * This computer software and information is distributed with "restricted
  51.  * rights."  Use, duplication or disclosure is subject to restrictions as
  52.  * set forth in NASA FAR SUP 18-52.227-79 (April 1985) "Commercial
  53.  * Computer Software-Restricted Rights (April 1985)."  If the Clause at
  54.  * 18-52.227-74 "Rights in Data General" is specified in the contract,
  55.  * then the "Alternate III" clause applies.
  56.  *
  57.  **************************************************************************/
  58.  
  59. #include <stdcomp.h>
  60.  
  61. #ifndef _RWSTD_HEADER_REQUIRES_HPP
  62. #include <memory>
  63. #include <functional>
  64. #include <rw/tree>
  65. #else
  66. #include <memory.hpp>
  67. #include <functional>
  68. #include "rw/tree.hpp"
  69. #endif
  70.  
  71. #ifndef _RWSTD_NO_NAMESPACE
  72. namespace __rwstd {
  73. #endif
  74.  
  75. //
  76. // This is used in the implementation of set and multiset.
  77. //
  78.  
  79. template <class T, class U>
  80. struct ident : public unary_function<T, U>
  81. {
  82.     const U& operator() (const T& x) const { return x; }
  83. };
  84.  
  85. #ifndef _RWSTD_NO_NAMESPACE
  86. }
  87.  
  88. namespace std {
  89. #endif
  90.  
  91. //
  92. // Note that _RWSTD_SIMPLE_DEFAULT(x) and _RWSTD_COMPLEX_DEFAULT(x)
  93. // will expand to: ' = x', or nothing,
  94. // depending on your compiler's capabilities and/or
  95. // flag settings (see stdcomp.h).
  96. //
  97. template <class Key, 
  98.           class Compare _RWSTD_COMPLEX_DEFAULT(less<Key>), 
  99.           class Allocator _RWSTD_SIMPLE_DEFAULT(allocator<Key>) >  
  100. class set
  101. {
  102.   public:
  103.     //
  104.     // Types
  105.     //
  106.     typedef Key                key_type;
  107.     typedef Key                value_type;
  108.     typedef Compare            key_compare;
  109.     typedef Compare            value_compare;
  110.     typedef Allocator          allocator_type;
  111.  
  112.   private:
  113.     
  114.     typedef __RWSTD::rb_tree<key_type, value_type, 
  115.                     __RWSTD::ident<value_type, key_type>, 
  116.                     key_compare, allocator_type> rep_type;
  117.     rep_type t;
  118.  
  119.   public:
  120.     //
  121.     // Types
  122.     //
  123.     typedef _TYPENAME rep_type::const_reference         reference;
  124.     typedef _TYPENAME rep_type::const_reference         const_reference;
  125.     typedef _TYPENAME rep_type::const_iterator          iterator;
  126.     typedef _TYPENAME rep_type::const_iterator          const_iterator;
  127.     typedef _TYPENAME rep_type::size_type               size_type;
  128.     typedef _TYPENAME rep_type::difference_type         difference_type;
  129.     typedef _TYPENAME rep_type::reverse_iterator        reverse_iterator;
  130.     typedef _TYPENAME rep_type::const_reverse_iterator  const_reverse_iterator;
  131.  
  132.     //
  133.     // construct/copy/destroy
  134.     //
  135.     _EXPLICIT set (const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()),
  136.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) : t(_RWSTD_COMP, false, alloc) {}
  137.  
  138. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  139.     set () : t(Compare(), false, Allocator()) {}
  140.  
  141.     _EXPLICIT set (const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare())) : t(_RWSTD_COMP, false, Allocator()) {}
  142. #endif
  143.  
  144. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  145.     template<class InputIterator>
  146.     set (InputIterator first, InputIterator last,
  147.          const Compare& comp = Compare(),
  148.          const Allocator& alloc = Allocator()) : t(comp, false, alloc)
  149.     {
  150.         while (first != last) t.insert(*first++);
  151.     }
  152. #else
  153.     set (const value_type* first, const value_type* last,
  154.          const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()),
  155.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) : t(_RWSTD_COMP, false, alloc)
  156.     {
  157.         while (first != last) t.insert(*first++);
  158.     }
  159.     
  160.     set (const_iterator first, const_iterator last,
  161.          const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()),
  162.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) : t(_RWSTD_COMP, false, alloc)
  163.     {
  164.         while (first != last) t.insert(*first++);
  165.     }
  166.  
  167. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  168.     set (const value_type* first, const value_type* last) : t(Compare(), false, Allocator())
  169.     {
  170.         while (first != last) t.insert(*first++);
  171.     }
  172.     
  173.     set (const value_type* first, const value_type* last,
  174.          const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare())) : t(_RWSTD_COMP, false, Allocator())
  175.     {
  176.         while (first != last) t.insert(*first++);
  177.     }
  178.     
  179.     set (const_iterator first, const_iterator last) : t(Compare(), false, Allocator())
  180.     {
  181.         while (first != last) t.insert(*first++);
  182.     }
  183.  
  184.     set (const_iterator first, const_iterator last,
  185.          const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare())) : t(_RWSTD_COMP, false, Allocator())
  186.     {
  187.         while (first != last) t.insert(*first++);
  188.     }
  189. #endif
  190. #endif
  191.  
  192.     set (const set<Key, Compare, Allocator>& x) : t(x.t, false) {}
  193.     set<Key, Compare, Allocator>& operator= (const set<Key, Compare, Allocator>& x)
  194.     {
  195.           t = x.t; return *this;
  196.     }
  197.     allocator_type get_allocator() const
  198.     {
  199.         return t.get_allocator();
  200.     }
  201.  
  202.     //
  203.     // iterators
  204.     //
  205.     iterator                 begin  ()       { return t.begin();  }
  206.     const_iterator           begin  () const { return t.begin();  }
  207.     iterator                 end    ()       { return t.end();    }
  208.     const_iterator           end    () const { return t.end();    }
  209.     reverse_iterator         rbegin ()       { return t.rbegin(); } 
  210.     const_reverse_iterator   rbegin () const { return t.rbegin(); } 
  211.     reverse_iterator         rend   ()       { return t.rend();   }
  212.     const_reverse_iterator   rend   () const { return t.rend();   }
  213.  
  214.     //
  215.     // capacity
  216.     //
  217.     bool        empty    () const { return t.empty();    }
  218.     size_type   size     () const { return t.size();     }
  219.     size_type   max_size () const { return t.max_size(); }
  220.  
  221.     //
  222.     // modifiers
  223.     //
  224. #ifdef _RWSTD_NO_MEMBER_TYPE_TPARAM
  225.     typedef _TYPENAME rep_type::iterator t_iterator;
  226. #endif
  227. #ifndef _RWSTD_NO_RET_TEMPLATE
  228.     pair<iterator,bool> insert (const value_type& x)
  229. #else
  230.     typedef pair<iterator, bool> pair_iterator_bool;
  231.     //
  232.     // typedef done to get around compiler bug.
  233.     //
  234.     pair_iterator_bool insert (const value_type& x)
  235. #endif
  236.     {
  237. #ifndef _RWSTD_NO_MEMBER_TYPE_TPARAM
  238.         pair<_TYPENAME rep_type::iterator, bool> p = t.insert(x); 
  239. #else
  240.         pair<t_iterator,bool> p = t.insert(x); 
  241. #endif
  242.         return pair<iterator, bool>(p.first, p.second);
  243.     }
  244.     iterator insert (iterator position, const value_type& x)
  245.     {
  246. #ifndef HPPA_WA       
  247.         return t.insert(_RWSTD_REINTERPRET_CAST(_TYPENAME rep_type::iterator&,position), x);
  248. #else
  249.         return t.insert(*(_TYPENAME rep_type::iterator*&)&position, x);
  250. #endif
  251.     }
  252.  
  253. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  254.     template<class InputIterator>
  255.     void insert (InputIterator first, InputIterator last)
  256.     {
  257.         while (first != last) t.insert(*first++);
  258.     }
  259. #else
  260.     void insert (const value_type* first, const value_type* last)
  261.     {
  262.         while (first != last) t.insert(*first++);
  263.     }
  264.     void insert (const_iterator first, const_iterator last)
  265.     {
  266.         while (first != last) t.insert(*first++);
  267.     }
  268. #endif
  269.  
  270.     iterator erase (iterator position)
  271.     {
  272. #ifndef HPPA_WA
  273.         return t.erase((_TYPENAME rep_type::iterator&)position);
  274. #else
  275.         return t.erase(*(_TYPENAME rep_type::iterator*&)&position);
  276. #endif
  277.     }
  278.     size_type erase (const key_type& x)
  279.     {
  280.         return t.erase(x); 
  281.     }
  282.     iterator erase (iterator first, iterator last)
  283.     {
  284. #ifndef HPPA_WA
  285.         return t.erase(_RWSTD_REINTERPRET_CAST(_TYPENAME rep_type::iterator&,first),
  286.                _RWSTD_REINTERPRET_CAST(_TYPENAME rep_type::iterator&,last));
  287. #else
  288.         return t.erase(*(_TYPENAME rep_type::iterator*&)&first,
  289.                        *(_TYPENAME rep_type::iterator*&)&last);
  290. #endif
  291.     }
  292.     void clear ()   { erase(begin(),end()); }
  293.     void swap (set<Key, Compare, Allocator>& x) { t.swap(x.t); }
  294.  
  295.     //
  296.     // observers
  297.     //
  298.     key_compare        key_comp   () const { return t.key_comp(); }
  299.     value_compare      value_comp () const { return t.key_comp(); }
  300.  
  301.     //
  302.     // set operations
  303.     //
  304.     iterator  find        (const key_type& x) const { return t.find(x);       }
  305.     size_type count       (const key_type& x) const { return t.count(x);      }
  306.     iterator  lower_bound (const key_type& x) const { return t.lower_bound(x);}
  307.     iterator  upper_bound (const key_type& x) const { return t.upper_bound(x);}
  308.  
  309. #ifndef _RWSTD_NO_RET_TEMPLATE
  310.     pair<iterator,iterator> equal_range(const key_type& x) const
  311. #else
  312.     typedef  pair<iterator, iterator> pair_iterator_iterator;
  313.     //
  314.     // typedef done to get around compiler bug
  315.     //
  316.     pair_iterator_iterator equal_range (const key_type& x) const
  317. #endif
  318.     {
  319.         return t.equal_range(x);
  320.     }
  321.  
  322. #ifndef _RWSTD_STRICT_ANSI
  323.     // Non-standard function for setting buffer allocation size
  324.     size_type allocation_size() { return t.allocation_size(); }
  325.     size_type allocation_size(size_type new_size) 
  326.     { 
  327.        return t.allocation_size(new_size);
  328.     }
  329. #endif  
  330. };
  331.  
  332. //
  333. // Note that _RWSTD_SIMPLE_DEFAULT(x) and _RWSTD_COMPLEX_DEFAULT(x)
  334. // will expand to: ' = x', or nothing,
  335. // depending on your compiler's capabilities and/or
  336. // flag settings (see stdcomp.h).
  337. //
  338. template <class Key, 
  339.           class Compare _RWSTD_COMPLEX_DEFAULT(less<Key>), 
  340.           class Allocator _RWSTD_SIMPLE_DEFAULT(allocator<Key>) > 
  341. class multiset
  342. {
  343.   public:
  344.     //  
  345.     // types
  346.     //
  347.     typedef Key       key_type;
  348.     typedef Key       value_type;
  349.     typedef Compare   key_compare;
  350.     typedef Compare   value_compare;
  351.     typedef Allocator allocator_type;
  352.   private:
  353.     
  354.     typedef __RWSTD::rb_tree<key_type, value_type,
  355.                     __RWSTD::ident<value_type, key_type>, 
  356.                     key_compare, allocator_type> rep_type;
  357.     rep_type t;
  358.  
  359.   public:
  360.     //
  361.     // types
  362.     //
  363.     typedef _TYPENAME rep_type::const_reference         reference;
  364.     typedef _TYPENAME rep_type::const_reference         const_reference;
  365.     typedef _TYPENAME rep_type::const_iterator          iterator;
  366.     typedef _TYPENAME rep_type::const_iterator          const_iterator;
  367.     typedef _TYPENAME rep_type::size_type               size_type;
  368.     typedef _TYPENAME rep_type::difference_type         difference_type;
  369.     typedef _TYPENAME rep_type::reverse_iterator        reverse_iterator;
  370.     typedef _TYPENAME rep_type::const_reverse_iterator  const_reverse_iterator;
  371.  
  372.     //
  373.     // construct/copy/destroy
  374.     //
  375.     _EXPLICIT multiset (const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()),
  376.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) : t(_RWSTD_COMP, true, alloc) {}
  377.  
  378. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  379.     _EXPLICIT multiset (void) : t(Compare(), true, Allocator()) {}
  380.  
  381.     _EXPLICIT multiset (const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare())) : t(_RWSTD_COMP, true, Allocator()) {}
  382. #endif
  383.  
  384. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  385.     template<class InputIterator>
  386.     multiset (InputIterator first, InputIterator last, 
  387.               const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()),
  388.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) : t(_RWSTD_COMP, true, alloc)
  389.     {
  390.         while (first != last) t.insert(*first++);
  391.     }
  392. #else
  393.     multiset (const value_type* first, const value_type* last, 
  394.               const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()),
  395.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) : t(_RWSTD_COMP, true, alloc)
  396.     {
  397.         while (first != last) t.insert(*first++);
  398.     }
  399.     multiset (const_iterator first, const_iterator last, 
  400.               const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare()),
  401.          const Allocator& alloc _RWSTD_DEFAULT_ARG(Allocator())) : t(_RWSTD_COMP, true, alloc)
  402.     {
  403.         while (first != last) t.insert(*first++);
  404.     }
  405.  
  406. #ifdef _RWSTD_NO_DEFAULT_TEMPLATE_ARGS
  407.     multiset (const value_type* first, const value_type* last) : t(Compare(), true, Allocator())
  408.     {
  409.         while (first != last) t.insert(*first++);
  410.     }
  411.  
  412.     multiset (const value_type* first, const value_type* last, 
  413.               const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare())) : t(_RWSTD_COMP, true, Allocator())
  414.     {
  415.         while (first != last) t.insert(*first++);
  416.     }
  417.  
  418.     multiset (const_iterator first, const_iterator last) : t(Compare(), true, Allocator())
  419.     {
  420.         while (first != last) t.insert(*first++);
  421.     }
  422.  
  423.     multiset (const_iterator first, const_iterator last, 
  424.               const Compare& _RWSTD_COMP _RWSTD_DEFAULT_ARG(Compare())) : t(_RWSTD_COMP, true, Allocator())
  425.     {
  426.         while (first != last) t.insert(*first++);
  427.     }
  428. #endif
  429.  
  430. #endif
  431.  
  432.     multiset (const multiset<Key, Compare, Allocator>& x) : t(x.t, true) {}
  433.     multiset<Key, Compare, Allocator>& 
  434.         operator= (const multiset<Key, Compare, Allocator>& x)
  435.     {
  436.         t = x.t; return *this;
  437.     }
  438.     allocator_type get_allocator() const
  439.     {
  440.         return t.get_allocator();
  441.     }
  442.  
  443.     //
  444.     // iterators
  445.     //
  446.     iterator                 begin  ()       { return t.begin();  }
  447.     const_iterator           begin  () const { return t.begin();  }
  448.     iterator                 end    ()       { return t.end();    }
  449.     const_iterator           end    () const { return t.end();    }
  450.     reverse_iterator         rbegin ()       { return t.rbegin(); } 
  451.     const_reverse_iterator   rbegin () const { return t.rbegin(); } 
  452.     reverse_iterator         rend   ()       { return t.rend();   }
  453.     const_reverse_iterator   rend   () const { return t.rend();   }
  454.  
  455.     //
  456.     // capacity
  457.     //
  458.     bool       empty    () const { return t.empty();    }
  459.     size_type  size     () const { return t.size();     }
  460.     size_type  max_size () const { return t.max_size(); }
  461.  
  462.     //
  463.     // modifiers
  464.     //
  465.     iterator insert (const value_type& x) { return t.insert(x).first; }
  466.     iterator insert (iterator position, const value_type& x)
  467.     {
  468. #ifndef HPPA_WA
  469.         return t.insert(_RWSTD_REINTERPRET_CAST(_TYPENAME rep_type::iterator&,position), x);
  470. #else
  471.         return t.insert(*(_TYPENAME rep_type::iterator*&)&position, x);
  472. #endif
  473.     }
  474.  
  475. #ifndef _RWSTD_NO_MEMBER_TEMPLATES
  476.     template<class InputIterator>
  477.     void insert (InputIterator first, InputIterator last)
  478.     {
  479.         while (first != last) t.insert(*first++);
  480.     }
  481. #else
  482.     void insert (const value_type* first, const value_type* last)
  483.     {
  484.         while (first != last) t.insert(*first++);
  485.     }
  486.     void insert (const_iterator first, const_iterator last)
  487.     {
  488.         while (first != last) t.insert(*first++);
  489.     }
  490. #endif
  491.  
  492.     iterator erase (iterator position)
  493.     {
  494. #ifndef HPPA_WA
  495.         return t.erase(_RWSTD_REINTERPRET_CAST(_TYPENAME rep_type::iterator&,position));
  496. #else
  497.         return t.erase(*(_TYPENAME rep_type::iterator*&)&position);
  498. #endif 
  499.     }
  500.     size_type erase (const key_type& x) { return t.erase(x); }
  501.     iterator erase (iterator first, iterator last)
  502.     {
  503. #ifndef HPPA_WA
  504.       return t.erase(_RWSTD_REINTERPRET_CAST(_TYPENAME rep_type::iterator&,first),
  505.              _RWSTD_REINTERPRET_CAST(_TYPENAME rep_type::iterator&,last)); 
  506. #else
  507.       return t.erase(*(_TYPENAME rep_type::iterator*&)&first,
  508.                      *(_TYPENAME rep_type::iterator*&)&last);
  509. #endif
  510.     }
  511.     void clear ()   { erase(begin(),end()); }
  512.     void swap (multiset<Key, Compare, Allocator>& x) { t.swap(x.t); }
  513.  
  514.     //
  515.     // observers
  516.     //
  517.     key_compare   key_comp   () const { return t.key_comp(); }
  518.     value_compare value_comp () const { return t.key_comp(); }
  519.  
  520.     //
  521.     // set operations
  522.     //
  523.     iterator  find        (const key_type& x) const { return t.find(x);  }
  524.     size_type count       (const key_type& x) const { return t.count(x); }
  525.     iterator  lower_bound (const key_type& x) const
  526.     {
  527.         return t.lower_bound(x);
  528.     }
  529.     iterator  upper_bound (const key_type& x) const
  530.     {
  531.         return t.upper_bound(x); 
  532.     }
  533. #ifndef _RWSTD_NO_RET_TEMPLATE
  534.     pair<iterator,iterator> equal_range (const key_type& x) const
  535. #else
  536.     typedef  pair<iterator, iterator> pair_iterator_iterator; 
  537.     //
  538.     // typedef done to get around compiler bug
  539.     //
  540.     pair_iterator_iterator equal_range (const key_type& x) const
  541. #endif
  542.     {
  543.         return t.equal_range(x);
  544.     }
  545.  
  546. #ifndef _RWSTD_STRICT_ANSI
  547.     // Non-standard function for setting buffer allocation size
  548.     size_type allocation_size() { return t.allocation_size(); }
  549.     size_type allocation_size(size_type new_size) 
  550.     { 
  551.        return t.allocation_size(new_size);
  552.     }
  553. #endif  
  554. };
  555.  
  556. template <class Key, class Compare, class Allocator>
  557. inline bool operator== (const set<Key, Compare, Allocator>& x, 
  558.                         const set<Key, Compare, Allocator>& y)
  559. {
  560.     return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());
  561. }
  562.  
  563. template <class Key, class Compare, class Allocator>
  564. inline bool operator< (const set<Key, Compare, Allocator>& x, 
  565.                        const set<Key, Compare, Allocator>& y)
  566. {
  567.     return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
  568. }
  569.  
  570. #if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  571. template <class Key, class Compare, class Allocator>
  572. inline bool operator!= (const set<Key,Compare,Allocator>& x, 
  573.                         const set<Key,Compare,Allocator>& y)
  574. {
  575.     return !(x == y);
  576. }
  577.  
  578. template <class Key, class Compare, class Allocator>
  579. inline bool operator> (const set<Key,Compare,Allocator>& x, 
  580.                        const set<Key,Compare,Allocator>& y)
  581. {
  582.     return y < x;
  583. }
  584.  
  585. template <class Key, class Compare, class Allocator>
  586. inline bool operator>= (const set<Key,Compare,Allocator>& x, 
  587.                         const set<Key,Compare,Allocator>& y)
  588. {
  589.     return !(x < y);
  590. }
  591.  
  592. template <class Key, class Compare, class Allocator>
  593. inline bool operator<= (const set<Key,Compare,Allocator>& x, 
  594.                         const set<Key,Compare,Allocator>& y)
  595. {
  596.     return !(y <  x);
  597. }
  598.  
  599. template <class Key, class Compare, class Allocator>
  600. void swap(set<Key,Compare,Allocator>& a, 
  601.           set<Key,Compare,Allocator>& b)
  602. {
  603.     a.swap(b);
  604. }
  605. #endif
  606.  
  607. template <class Key, class Compare, class Allocator>
  608. inline bool operator== (const multiset<Key, Compare, Allocator>& x, 
  609.                         const multiset<Key, Compare, Allocator>& y)
  610. {
  611.     return x.size() == y.size() && equal(x.begin(), x.end(), y.begin());
  612. }
  613.  
  614. template <class Key, class Compare, class Allocator>
  615. inline bool operator< (const multiset<Key, Compare, Allocator>& x, 
  616.                        const multiset<Key, Compare, Allocator>& y)
  617. {
  618.     return lexicographical_compare(x.begin(), x.end(), y.begin(), y.end());
  619. }
  620.  
  621. #if !defined(_RWSTD_NO_NAMESPACE) || !defined(_RWSTD_NO_PART_SPEC_OVERLOAD)
  622. template <class Key, class Compare, class Allocator>
  623. inline bool operator!= (const multiset<Key,Compare,Allocator>& x, 
  624.                         const multiset<Key,Compare,Allocator>& y)
  625. {
  626.     return !(x == y);
  627. }
  628.  
  629. template <class Key, class Compare, class Allocator>
  630. inline bool operator> (const multiset<Key,Compare,Allocator>& x, 
  631.                        const multiset<Key,Compare,Allocator>& y)
  632. {
  633.     return y < x;
  634. }
  635.  
  636. template <class Key, class Compare, class Allocator>
  637. inline bool operator>= (const multiset<Key,Compare,Allocator>& x, 
  638.                         const multiset<Key,Compare,Allocator>& y)
  639. {
  640.     return !(x < y);
  641. }
  642.  
  643. template <class Key, class Compare, class Allocator>
  644. inline bool operator<= (const multiset<Key,Compare,Allocator>& x, 
  645.                         const multiset<Key,Compare,Allocator>& y)
  646. {
  647.     return !(y <  x);
  648. }
  649.  
  650. template <class Key, class Compare, class Allocator>
  651. void swap(multiset<Key,Compare,Allocator>& a, 
  652.           multiset<Key,Compare,Allocator>& b)
  653. {
  654.     a.swap(b);
  655. }
  656. #endif
  657.  
  658. #ifndef _RWSTD_NO_NAMESPACE
  659. }
  660. #endif
  661.  
  662. #pragma option pop
  663. #endif /* __STD_SET__ */
  664.